package com.ruoyi.system.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.YyAchievementMapper;
import com.ruoyi.system.domain.YyAchievement;
import com.ruoyi.system.service.IYyAchievementService;
import com.ruoyi.common.core.text.Convert;

/**
 * 学生课程成绩关联Service业务层处理
 *
 * @author ruoyi
 * @date 2024-05-13
 */
@Service
public class YyAchievementServiceImpl implements IYyAchievementService
{
    @Autowired
    private YyAchievementMapper yyAchievementMapper;

    /**
     * 查询学生课程成绩关联
     *
     * @param id 学生课程成绩关联主键
     * @return 学生课程成绩关联
     */
    @Override
    public YyAchievement selectYyAchievementById(Long id)
    {
        return yyAchievementMapper.selectYyAchievementById(id);
    }

    /**
     * 查询学生课程成绩关联列表
     *
     * @param yyAchievement 学生课程成绩关联
     * @return 学生课程成绩关联
     */
    @Override
    public List<YyAchievement> selectYyAchievementList(YyAchievement yyAchievement)
    {

        //根据当前userid 获取 角色
        //如 家长角色就 获取自己孩子的信息
        Integer roleId = yyAchievementMapper.getRoleIdByUserId(yyAchievement.getUserId());
        if (roleId != null){
            yyAchievement.setRoleId(roleId);
        }
        yyAchievement.setpId(yyAchievement.getUserId());

        return yyAchievementMapper.selectYyAchievementList(yyAchievement);
    }

    /**
     * 新增学生课程成绩关联
     *
     * @param yyAchievement 学生课程成绩关联
     * @return 结果
     */
    @Override
    public int insertYyAchievement(YyAchievement yyAchievement)
    {
        return yyAchievementMapper.insertYyAchievement(yyAchievement);
    }

    /**
     * 修改学生课程成绩关联
     *
     * @param yyAchievement 学生课程成绩关联
     * @return 结果
     */
    @Override
    public int updateYyAchievement(YyAchievement yyAchievement)
    {
        return yyAchievementMapper.updateYyAchievement(yyAchievement);
    }

    /**
     * 批量删除学生课程成绩关联
     *
     * @param ids 需要删除的学生课程成绩关联主键
     * @return 结果
     */
    @Override
    public int deleteYyAchievementByIds(String ids)
    {
        return yyAchievementMapper.deleteYyAchievementByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除学生课程成绩关联信息
     *
     * @param id 学生课程成绩关联主键
     * @return 结果
     */
    @Override
    public int deleteYyAchievementById(Long id)
    {
        return yyAchievementMapper.deleteYyAchievementById(id);
    }
}
